﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
   public class TheLoaiTaiLieu_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable TaoBang(string sql)
       {
           return kn.taobang(sql);
       }
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_TheLoaiTaiLieu");
       }
       public int Insert(TheLoaiTaiLieu_Public maTheLoai, TheLoaiTaiLieu_Public tenTheLoai, TheLoaiTaiLieu_Public ghiChu)
       {
           int Npara = 3;
           string[] name = new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@MaTheLoai";
           value[0] = maTheLoai.MaTheLoai;
           name[1] = "@TenTheLoai";
           value[1] = tenTheLoai.TenTheLoai;
           name[2] = "@GhiChu";
           value[2] = ghiChu.GhiChu;

           return kn.update("Insert_TheLoaiTaiLieu",name,value,Npara);
       }
       public int Update(TheLoaiTaiLieu_Public maTheLoai, TheLoaiTaiLieu_Public tenTheLoai, TheLoaiTaiLieu_Public ghiChu)
       {
           int Npara = 3;
           string[] name = new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@MaTheLoai";
           value[0] = maTheLoai.MaTheLoai;
           name[1] = "@TenTheLoai";
           value[1] = tenTheLoai.TenTheLoai;
           name[2] = "@GhiChu";
           value[2] = ghiChu.GhiChu;

           return kn.update("Update_TheLoaiTaiLieu", name, value, Npara);
       }
       public int Delete(TheLoaiTaiLieu_Public maTheLoai)
       {
           int Npara = 1;
           string[] name = new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@MaTheLoai";
           value[0] = maTheLoai.MaTheLoai;

           return kn.update("Delete_TheLoaiTaiLieu", name, value, Npara);
       }
    }
}
